let form = layui.form;

function renderUser() {
    $.ajax({
        url: '/my/user/userinfo',
        success:function (res) {
            // console.log(res);
            form.val('formFir', res.data)
        }
    })
}

function updateUserInfo(data) {
    $.ajax({
        type:'post',
        url:'/my/user/userinfo',
        data:data,
        success:function (res) {
            layer.msg(res.message);
            if (res.status === 0) {
                window.parent.getUserInfo();
            }
        }
    })
}

renderUser()

$('form').on('submit',function (e) {
    e.preventDefault();
    let data = $(this).serialize();
    updateUserInfo(data)
})

$('.reset').on('click', function (e) {
    e.preventDefault();
    renderUser()
})